import java.io.*;
import java.net.*;
 /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Samanthol
 */
public class ComunicaTCPClient extends Thread {
    private InetAddress addrClient;
    private int portClient;
    private Socket sockClient;

    public ComunicaTCPClient(InetAddress addrClient, int port) {
        this.addrClient = addrClient;
        this.portClient = port;
    }
    
    public void run() {
        try {
            this.sockClient = new Socket(addrClient, portClient);
            
            //System.out.println("In " + ComunicaTCPServer.class.getName() + " : Accepted a client");
            InputStreamReader inReader = new InputStreamReader(sockClient.getInputStream());
            OutputStreamWriter outWriter = new OutputStreamWriter(sockClient.getOutputStream());
            BufferedReader br = new BufferedReader(inReader);
            BufferedWriter bw = new BufferedWriter(outWriter);
            
            Communica com = new Communica(bw, br,"client");
            com.setDefaultCloseOperation(Communica.EXIT_ON_CLOSE);
        } catch (IOException ex) {
            System.err.println("Erreur in : " + ComunicaTCPClient.class.getName().toString() + " : " + ex.getMessage());
        }
    }
    public static void main(String[] args) throws UnknownHostException {
        ComunicaTCPClient client=new ComunicaTCPClient(InetAddress.getByName("10.1.1.31"), 12345);
        client.run();
    }
    
}
